<template>
    <view>
        <custom><template #backText>修改密码</template></custom>
        <nFormItem title="原密码" text_lr="right" :data.sync="data" field="old_password_md5" :password="true"></nFormItem>
        <nFormItem title="新密码" text_lr="right" :data.sync="data" field="new_password_md5" :password="true"></nFormItem>
        <nFormButton title="修改密码" :tap="update"></nFormButton>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                data: {
                    formtag: {},
                    form: {
                        old_password_md5: '',
                        new_password_md5: ''
                    },
                }
            }
        },
        methods: {
            update() {
                this.$api.post(this, {
                    loading: '修改密码中',
                    url: '/account/password/updateByOld',
                    success: (Result) => {
                        if (this.$api.form.toast(this, Result)) return;
                        this.$store.commit('userToastSuccess', {
                            message: '修改成功',
                            commit: 'appBackPage'
                        });
                    }
                });
            }
        },
    }
</script>
